package com.qu.waibao.my.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TableRow;
import android.widget.TextView;

import com.qu.waibao.R;
import com.qu.waibao.base.BaseRecyclerAdapter;
import com.qu.waibao.bean.Hexiao;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @描述 describe
 * @作者 Administrator
 * @创建时间 2018/7/24 11:16
 * @邮箱 1123599561@qq.com
 */
public class HexaioAdapter extends BaseRecyclerAdapter<Hexiao.TotalMonthBean> {
    public HexaioAdapter(Context context, int mode) {
        super(context, mode);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateDefaultViewHolder(ViewGroup parent, int type) {
        return new HexiaoViewHodler(mInflater.inflate(R.layout.hexiao_parent_recycler,parent,false));
    }

    @Override
    protected void onBindDefaultViewHolder(RecyclerView.ViewHolder holder, Hexiao.TotalMonthBean item, int position) {
        HexiaoViewHodler hexiaoViewHodler = (HexiaoViewHodler) holder;
        hexiaoViewHodler.tv_month.setText(item.getDate_tj());
        hexiaoViewHodler.tv_money.setText("¥ "+item.getMoneysubtract_total());
        ChildHeAdapter childHeAdapter = new ChildHeAdapter(mContext,BaseRecyclerAdapter.NEITHER);
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
        hexiaoViewHodler.recyclerView.setNestedScrollingEnabled(false);
        hexiaoViewHodler.recyclerView.setHasFixedSize(true);
        hexiaoViewHodler.recyclerView.setLayoutManager(layoutManager);
        hexiaoViewHodler.recyclerView.setAdapter(childHeAdapter);
        if(childHeAdapter.getItems().size() == 0){
            childHeAdapter.clear();
            childHeAdapter.addAll(item.getChild());
        }
    }


    class HexiaoViewHodler extends RecyclerView.ViewHolder{
        @BindView(R.id.recyclerView)
        RecyclerView recyclerView;
        @BindView(R.id.tv_money)
        TextView tv_money;
        @BindView(R.id.tv_month)
        TextView tv_month;
        public HexiaoViewHodler(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
